package day06.JavaHomework;

import java.util.Random;
import java.util.Scanner;

public class StandardPractice {
    public static void main(String[] args) {
        int a = sum1(5, 4);
        System.out.println(a);
        int[] array1 = generateArray(5);
        for (int i = 0; i < array1.length; i++) {
            System.out.println(array1[i]);
        }

    }

    /*
          Q2.方法的练习：返回值
            1) 定义sum()两个参有返回值方法，调用测试
            2) 定义generateArray()用于生成整型数组填充随机数并返回数组，调用测试
         */
    //第一遍:
    public static void say1() {

    }

    public static void say1(String name1) {

    }

    public static void say1(String name1, int age1) {

    }

    public static int sum1 (int num1, int num2) {
        int totalVal = num1 + num2;
        return totalVal;
    }

    public static int[] generateArray(int count) {
        Random rand1 = new Random();
        int[] array1 = new int[count];
        for (int i = 0; i < array1.length; i++) {
            array1[i] = rand1.nextInt(100);
        }
        return array1;
    }

    /*
        double[] score3 = inputVal3(5);
        double avg3 = getAvg3(score3);
        System.out.println("平均值为: " + avg3);
    }
     */

    /*
      Q3.综合练习一：
       1) 需求:<<主持人大赛>>有N位评委给选手打分
       2) 选手的最终得分为:去掉最高分和最低分之后的N-2位评委的平均分
       3) 要求:使用方法实现
     */
    //第三遍:
    /*
    public static double[] inputVal3(int numVal3) {
        Scanner scan3 = new Scanner(System.in);
        double[] score3 = new double[numVal3];
        for (int i = 0; i < score3.length; i++) {
            System.out.println("请输入第" + (i + 1) + "位评委的评分为: ");
            score3[i] = scan3.nextDouble();
        }
        return score3;
    }

    public static double getAvg3(double[] inputVal3) {
        double max3 = inputVal3[0];
        double min3 = inputVal3[0];
        double totalVal3 = 0.0;

        for (int i = 0; i < inputVal3.length; i++) {
            totalVal3 += inputVal3[i];
            if (inputVal3[i] > max3) {
                max3 = inputVal3[i];
            } else if (inputVal3[i] < min3) {
                min3 = inputVal3[i];
            }
        }
        double avg3 = (totalVal3 - max3 - min3) / (inputVal3.length - 2);
        return avg3;
    }
     */


        /*
        double[] score2 = inputVal2(5);
        double avg2 = getAvg2(score2);
        System.out.println("平均值为: " + avg2);
    }
         */

    /*
      Q3.综合练习一：
       1) 需求:<<主持人大赛>>有N位评委给选手打分
       2) 选手的最终得分为:去掉最高分和最低分之后的N-2位评委的平均分
       3) 要求:使用方法实现
     */
    //第二遍:
        /*
    public static double[] inputVal2(int numPeople2) {
        Scanner scan2 = new Scanner(System.in);
        double[] score2 = new double[numPeople2];
        for (int i = 0; i < score2.length; i++) {
            System.out.println("第" + (i + 1) + "位评委的评分为: ");
            score2[i] = scan2.nextDouble();
        }
        return score2;
    }

    public static double getAvg2(double[] inputVal2) {
        double max2 = inputVal2[0];
        double min2 = inputVal2[0];
        double totalVal2 = 0.0;

        for (int i = 0; i < inputVal2.length; i++) {
            totalVal2 += inputVal2[i];
            if (max2 < inputVal2[i]) {
                max2 = inputVal2[i];
            } else if (min2 > inputVal2[i]) {
                min2 = inputVal2[i];
            }
        }
        double avg2 = (totalVal2 - max2 - min2) / (inputVal2.length -2);
        return avg2;
    }
         */


    /*
        double[] score1 = inputVal1(10);
        double avg1 = getAvg1(score1);
        System.out.println("平均分为: " + avg1);
    }
    /*
      Q3.综合练习一：
       1) 需求:<<主持人大赛>>有N位评委给选手打分
       2) 选手的最终得分为:去掉最高分和最低分之后的N-2位评委的平均分
       3) 要求:使用方法实现
     */

    //第一遍:
    //该方法用来表示评委的评分
    /*
    public static double[] inputVal1 (int numPeople1) {
        double[] score1 = new double[numPeople1];
        Scanner scan1 = new Scanner(System.in);
        for (int i = 0; i < score1.length; i++) {
            System.out.println("请输入第" + (i + 1) + "位评委的评分为: ");
            score1[i] = scan1.nextDouble();

        }
        return score1;
    }

    //该方法来求出最终的平均值
    public static double getAvg1 (double[] inputVal1){
            double totalVal1 = 0.0;
            double max1 = inputVal1[0];
            double min1 = inputVal1[0];
            for (int i = 0; i < inputVal1.length; i++) {
                totalVal1 += inputVal1[i];
                if (max1 < inputVal1[i]) {
                    max1 = inputVal1[i];
                } else if (min1 > inputVal1[i]) {
                    min1 = inputVal1[i];
                }
            }
            totalVal1 = totalVal1 - max1 - min1;
            double avg1 = totalVal1 / (inputVal1.length - 2);
            return avg1;
        }
     */




        /*
           Q4.综合练习二：
            1) 完成猜数字小游戏
            2) 要求：使用while(true)自造死循环实现
         */
        //第一遍:
            /*
            Scanner scan1 = new Scanner(System.in);
            Random rand1 = new Random();
            int realNum1 = rand1.nextInt(1000) + 1;
            System.out.println(realNum1); //作弊, 方便编写和测试代码

            while (true) {
                System.out.println("猜吧!");
                int guessNum1 = scan1.nextInt();
                if (guessNum1 > realNum1) {
                    System.out.println("猜大了!");
                } else if (guessNum1 < realNum1) {
                    System.out.println("猜小了");
                } else {
                    System.out.println("恭喜您猜对了!");
                    break;
                }
            }
             */

        //第二遍:
            /*
            Scanner scan2 = new Scanner(System.in);
            Random rand2 = new Random();
            int realNum2 = rand2.nextInt(1000) + 1;
            System.out.println(realNum2); //作弊, 方便编写和测试代码

            while (true) {
                System.out.println("猜吧!");
                int guessNum2 = scan2.nextInt();
                if (guessNum2 < realNum2) {
                    System.out.println("猜小了!");
                } else if (guessNum2 > realNum2) {
                    System.out.println("猜大了!");
                } else {
                    System.out.println("恭喜您猜对了!");
                    break;
                }
            }
             */

        //第三遍:
            /*
            Scanner scan3 = new Scanner(System.in);
            Random rand3 = new Random();
            int realNum3 = rand3.nextInt(1000) + 1;
            System.out.println(realNum3); //作弊, 方便编写和测试代码

            while (true) {
                System.out.println("猜吧!");
                int guessNum3 = scan3.nextInt();
                if (guessNum3 > realNum3) {
                    System.out.println("猜大了!");
                } else if (guessNum3 < realNum3) {
                    System.out.println("猜小了!");
                } else {
                    System.out.println("恭喜您猜对了!");
                    break;
                }
            }
             */

        //第四遍:
            /*
            Scanner scan4 = new Scanner(System.in);
            Random rand4 = new Random();
            int realVal4 = rand4.nextInt(1000) + 1;
            System.out.println(realVal4); //作弊, 方便进行编写和测试代码

            while (true) {
                System.out.println("猜吧!");
                int guessVal4 = scan4.nextInt();
                if (guessVal4 > realVal4) {
                    System.out.println("猜大了!");
                } else if (guessVal4 < realVal4) {
                    System.out.println("猜小了!");
                } else {
                    System.out.println("恭喜您猜对了!");
                    break;
                }
            }
             */

}
